package interfaces.clients.dispatcher.commands;

import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * @author Mihail A. Muhin
 */
public class PutFileCommand extends BaseCommand {
	private String filename = null;

	private String contents = null;

	public String getFilename() {
		return filename;
	}

	public String getContents() {
		return contents;
	}

	public PutFileCommand(String filename, String contents) {
		this.filename = filename;
		this.contents = contents;
	}


	public void read(ObjectInputStream ois) throws NoClassCorrectableDebugException, ReadCorrectableException {
		try {
			filename = (String) (ois.readObject());
			contents = (String) (ois.readObject());
		} catch (IOException e) {
			throw new ReadCorrectableException("Error while reading user command from a stream");
		} catch (ClassNotFoundException e) {
			throw new NoClassCorrectableDebugException("Class is not found", e);
		}
	}

	public PutFileCommand() {

	}
}
